/***************************************************************************
 *   Copyright (C) 2005 by cyril dupuit                                    *
 *   cyrildupuit@hotmail.com                                               *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/

#include "Kernel/Types.h"
#include "Paging.h"

#ifndef MM_CONTEXT_HEADER
#define MM_CONTEXT_HEADER

//*****************************************************************************

/**
 * Definition of an MMU context.
 */
struct MmContext
{
	/** Physical address of the PD for this MMU context */
	PhysAddr_t paddr_PD;
	
	/** Virtual address where it is mapped into the Kernel space */
	VirtAddr_t vaddr_PD;
	
	/** Reference counter for this mm_context */
	unsigned long  RefCount;
	
	/** List of MMU contexts in the system */
	struct MmContext * pPrev;
	struct MmContext * pNext;
};

//*****************************************************************************

Status_t MmContextInit(void);


struct MmContext * MmContextCreate(void);


struct MmContext * MmContextDuplicate(const struct MmContext *model);


Status_t MmContextUnref(struct MmContext *mmctxt);


Status_t MmContextRef(struct MmContext *mmctxt);


Status_t MmContextSwitchTo(struct MmContext *mmctxt);


struct MmContext *MmContextGetCurrent();


/* ******************************************************
 * Reserved functions
 */


Status_t MmContextSynchKernelPDE(unsigned int index_in_pd, unsigned long pde);

//*****************************************************************************
#endif
